﻿var Xor_key = "";


// md5加密
document.getElementById('but_md5').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    console.log(typeof(input_msg));
    var res = md5(input_msg);
    document.getElementById("res").innerHTML= res;
});

// base64加密
document.getElementById('but_bse').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    var res = Base64Encode(input_msg);
    console.log(res);
    document.getElementById("res").innerHTML= res;
});

// base64解密
document.getElementById('but_bsd').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    var res = Base64Decode(input_msg);
    document.getElementById("res").innerHTML= res;
});

// 异或加密
document.getElementById('but_xor_e').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    var res = XorEncodeStr(input_msg,Xor_key);
    document.getElementById("res").innerHTML= res;
});

// 异或解密
document.getElementById('but_xor_d').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    var res = XorDecodeStr(input_msg,Xor_key);
    document.getElementById("res").innerHTML= res;
});


// 异或解密
document.getElementById('but_sj').addEventListener('click', function()
{
    var input_msg = document.getElementById("msg").value;
    
    var res = XorString(input_msg,Xor_key);
    console.log(res);
    document.getElementById("res").innerHTML= res;
});


$('body').on('click', '.btn-copy', function () {
    console.log("click");
       //var content = $(this).data('content'); data获取的是初始值 后边值改变则获取的还是初始值 不适用
    var content=$(this).attr('data-content');
    if (!content) {
        content = $(this).text().replace(/\s/g, '');
    }
    if (content) {
        $('body').append('<input type="text" class="copy-input" value="' + content + '"/>');
        $('body .copy-input:last')[0].select();
        if (document.execCommand('copy')) {
            Msg.Notify('复制成功');
        }
        $('body .copy-input').remove();
    }
});



